package entities;

import java.awt.Graphics2D;

/**
 *
 * @author casshern
 */
public class Attack extends GameObject {

    public static final int COST = 100;
    public static final int DAMAGE = 50;
    private int destX, destY;
    private int speed = 2;

    public Attack(int playerID, int x, int y, boolean alive) {
        this.playerID = playerID;
        this.type = GameObject.ATTACK;
        this.x = x;
        this.y = y;
        this.alive = alive;
        size = 20;
        maxHealth = 100;
        currentHealth = maxHealth;
    }

    public Attack(int playerID, int x, int y, int currentHealth, boolean alive) {
        this.playerID = playerID;
        this.type = GameObject.ATTACK;
        this.x = x;
        this.y = y;
        this.currentHealth = currentHealth;
        this.alive = alive;
        size = 20;
        maxHealth = 100;
    }

    @Override
    public void drawObject(Graphics2D g) {
        if (alive) {
            ImageMemory.ATTACK.paintIcon(null, g, x, y);
        }//else part: there is no picture for Attack Dead
    }

    public void setDestination(int x, int y) {
        destX = x;
        destY = y;
    }

    public int getDestX() {
        return destX;
    }

    public int getDestY() {
        return destY;
    }

    //Attack moves
    //Returns true if it arrave at the destination
    //Otherwise returns false
    public boolean move() {
        for (int i = 0; i < speed; i++) {
            if (x < destX) {
                x++;
            } else if (x > destX) {
                x--;
            }
            if (y < destY) {
                y++;
            } else if (y > destY) {
                y--;
            }
            if (x == destX && y == destY) {
                alive = false;
                return true;
            }
        }
        return false;
    }
}
